<template>
  <div>
    <el-row>
  <el-col :span="18" :offset="4">
    <!-- 搜索部分 -->
    <el-form :inline="true"  class="demo-form-inline">
  <el-form-item label="核心企业">
    <el-input  placeholder="请输入企业名称" v-model="fname"></el-input>
  </el-form-item>
  <el-form-item label="融资企业">
    <el-input  placeholder="请输入企业名称" v-model="ename"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="dofind()">查询</el-button>
  </el-form-item>
  <el-form-item>
    <el-button type="danger" @click="goaheadtend()">放款</el-button>
  </el-form-item>
</el-form>
  </el-col>

</el-row>

<!-- 表格部分 -->
<el-row>
  <el-col :span="24">
    <el-table
    :data="tableData"
    stripe
    border
    style="width: 100%"
    @selection-change="handleSelectionChange">
    <!-- 复选框 -->
    <el-table-column
      type="selection"
      width="55">
    </el-table-column>
    <el-table-column
      prop="tenderId"
      label="编号"
      width="180">
    </el-table-column>
    <el-table-column
      prop="fname"
      label="核心企业"
      width="180">
    </el-table-column>
    <el-table-column
      prop="ename"
      label="融资企业"
      width="180">
    </el-table-column>
    <el-table-column
      prop="repaymentAmount"
      label="待还总金额"
      width="180">
    </el-table-column>

    <el-table-column
      prop="allFinancingAmount"
      label="融资总金额"
      width="180">
    </el-table-column>
    <el-table-column
      prop="tenderIssuanceTime"
      label="发标时间"
      width="180">
    </el-table-column>
    <el-table-column
      prop="finalRepaymentTime"
      label="最终还款时间"
      width="180">
    </el-table-column>
    </el-table>
  </el-col>
</el-row>


  <!-- 分页部分 -->
    <el-row>
      <el-col :span="18">
        <el-pagination
    background
    :page-sizes="[1, 2, 3, 4]"
    :page-size="pageSize"
    :current-page="pageNumber"
    layout="total, sizes,prev, pager, next"
    @prev-click="prevPage"
    @next-click="nextPage"
    @size-change="sizeChange"
    @current-change="currentChange"
    :total="total">
  </el-pagination>
      </el-col>
    </el-row>

  </div>
</template>

<script>
export default {
    data(){
        return{
            total:0,
            fname:'',
            ename:'',
            pageSize:2,
            pageNumber:1,
            tableData:[],
            list:''
        }
    },
    methods:{
        handleSelectionChange(val){
            console.log(val)
           this.list = val
        },
        goaheadtend(){
            this.$axios.post('api/finance/tender/goaheadtend',this.list,{headers:{'jwt':localStorage.getItem('jwt')}})
            .then(res =>{
                console.log(res.data)
                if(res.data.code == 200){
                  this.$message({
                    message:'放款成功！',
                    type:'info'
                  })
                }
                this.queryList()
            })
        },
        dofind(){
            this.queryList()
            this.fname=''
            this.ename = ''
        },
        queryList(){
            let parm ={};
            parm.pageNum = this.pageNumber;
            parm.pageSize = this.pageSize;
            let data = {};
            data.fname = this.fname;
            data.ename = this.ename;
            parm.data = data;
            this.$axios.post('api/finance/tender/fulllist',parm,{headers:{'jwt':localStorage.getItem('jwt')}})
            .then(res =>{
                console.log(res.data)
                let pageData = res.data.data;
                this.tableData = pageData.list;
                this.pageNumber = pageData.pageNum;
                this.pageSize = pageData.pageSize;
                this.total = pageData.total;
            })
            
        },
        prevPage(val){
            this.pageNumber = val
            this.queryList()
        },
        nextPage(val){
            this.pageNumber = val
            this.queryList()
        },
        sizeChange(val){
            this.pageSize = val
             this.pageNumber = 1;
             this.queryList()
        },
        currentChange(val){
            this.pageNumber = val
            this.queryList()
        },
    },
    created(){
        this.queryList()
    }

}
</script>

<style>

</style>